package com.huabo.system.oracle.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huabo.system.oracle.entity.TblFinanceData;
import com.huabo.system.oracle.entity.TblOrganization;
import com.huabo.system.oracle.entity.TblYyUserQuery;
import com.hbfk.util.PageInfo;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author huabo
 * @since 2021-10-19
 */
public interface TblFinanceDataMapper extends BaseMapper<TblFinanceData> {

    @Select("delete from BATHDATA.TBL_FINANCEDATA WHERE ORDERID= #{orderId}")
    void deleteByorderid(String orderId);


    @SelectProvider(type=TblFinanceDataMapperSqlConfig.class,method="selectListByPageInfo")
    List<TblFinanceData> selectListByPageInfo(PageInfo<TblFinanceData> pageInfo, BigDecimal orgid);

    @Select("SELECT COUNT(*) FROM BATHDATA.TBL_FINANCEDATA A LEFT JOIN BATHDATA.TBL_VERSION B ON A.FID=B.FID where 1=1 and A.STATUS=1 AND A.COMPANYID= #{orgid}")
    Integer selectCountByPageInfo(PageInfo<TblFinanceData> pageInfo, BigDecimal orgid);


    @Select("SELECT A.*,B.FVENDOR FROM BATHDATA.TBL_FINANCEDATA A LEFT JOIN BATHDATA.TBL_VERSION B ON A.FID=B.FID WHERE STATUS=1  AND COMPANYID= #{companyid} AND  ORDERID != #{orderId}")
    List<TblFinanceData> selectDateByCompanyidAndOrderId(BigDecimal companyid, BigDecimal orderId);

    @Select("SELECT A.*,B.FVENDOR FROM BATHDATA.TBL_FINANCEDATA A LEFT JOIN BATHDATA.TBL_VERSION B ON A.FID=B.FID WHERE STATUS=1  AND COMPANYID= #{companyid}")
    List<TblFinanceData> selectDateByCompanyid(BigDecimal companyid);


    @Select("SELECT A.*,B.FVENDOR FROM BATHDATA.TBL_FINANCEDATA A LEFT JOIN BATHDATA.TBL_VERSION B ON A.FID=B.FID where 1=1 and A.STATUS=2 AND A.COMPANYID= #{companyid} and rownum=1")
    TblFinanceData selectModuleName(BigDecimal companyid);

    @Insert("select count(*) from dba_users WHERE USERNAME= #{newBookName}")
    int checkSchema(String newBookName);

    @Select("SELECT * FROM BATHDATA.TBL_FINANCEDATA WHERE ORDERID= #{selectid}")
    TblFinanceData selectByOrderId(String selectid);

    @InsertProvider(type=TblFinanceDataMapperSqlConfig.class,method="saveFirst")
    Integer saveFirst(TblFinanceData tlf);

    @UpdateProvider(type=TblFinanceDataMapperSqlConfig.class,method="updateFin")
    void updateFin(TblFinanceData tlf);

//    @Select("SELECT MODELNAME FROM BATHDATA.TBL_ORG_EXCELMODEL WHERE ORGID = #{orgid} AND TYPEID = #{type}")
//    String selectName(Integer type, BigDecimal orgid);

    @Select("SELECT MODELNAME FROM BATHDATA.TBL_ORG_EXCELMODEL WHERE TYPEID = #{type}")
    String selectName(Integer type, BigDecimal orgid);

}
